<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('题目列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>题库分类：</label>
                                <select name="typeId"  >
                                    <option value="">所有</option>
                                    <option th:each="type:${typeList}" th:text="${type.name}" th:value="${type.id}"></option>
                                </select>
                            </li>
                            <li>
                                <label>类型：</label>
                                <select name="questionType" th:with="type=${@dict.getType('tb_question_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('module:question:edit')}]];
        var removeFlag = [[${@permission.hasPermi('module:question:remove')}]];
        var types = [[${@dict.getType('tb_question_type')}]];
        var prefix = ctx + "module/question";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "题目",
                pageSize:50,
                rememberSelected:true,
                showColumns: false,
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id', 
                    title: '主键id',
                    visible: false
                },
                    {
                        field: 'title',
                        title: '题目名称',
                        width:400
                    },

                {
                    field: 'typeName',
                    title: '分类',
                    width:120
                },
                {
                    field: 'questionType', 
                    title: '类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(types, value);
                    },
                    width:120
                }]
            };
            $.table.init(options);
        });

        function detail(id) {
            var url = prefix+"/detail/"+id;
            $.modal.open("详情",url);
        }

        function submitHandler(index, layero) {
            var rows = $.table.selectFirstColumns();
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            parent.$('#questionIds').val(rows.join());
            $.modal.close();
            var ids = rows.join();
            console.log(ids);
            try {
                    if (typeof (parent.eval("getQuestions")) == "function") {
                        parent.getQuestions(ids);
                    }
            } catch (e) {
            }
        }
    </script>
</body>
</html>